package com.tongji.admin.view
{
	import com.tongji.admin.model.DictModel;
	import com.tongji.admin.utils.PopUpAdmin;
	import com.tongji.admin.view.popup.AddPictureTitleWin;
	
	import flash.events.MouseEvent;
	
	import mx.binding.utils.BindingUtils;
	import mx.managers.PopUpManager;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/7/
	 */ 
	public class PictureAdminMediator extends Mediator
	{
		[Inject]
		public var view:PictureAdminView;
		
		[Inject]
		public var model:DictModel;
		
		override public function onRegister():void
		{
			view.addPicture.addEventListener(MouseEvent.CLICK, popupHandler);
			BindingUtils.bindProperty(view.picType, "dataProvider", model, "picTypeXML");
			view.addType.addEventListener(MouseEvent.CLICK, popupAddHandler);
		}
		
		private function popupAddHandler(event:MouseEvent):void
		{
			PopUpAdmin.popupCenterWindow("addType", view, mediatorMap, false);
		}
		
		private function popupHandler(event:MouseEvent):void
		{
			var addPicTitleWin:AddPictureTitleWin = new AddPictureTitleWin();
			PopUpManager.addPopUp(addPicTitleWin, view, true);
			PopUpManager.centerPopUp(addPicTitleWin);
			mediatorMap.createMediator(addPicTitleWin);
		}
	}
}